FROM maven:3.8.5-openjdk-8 as builder
VOLUME m2repo:/root/.m2
COPY settings.xml /
# 拉取代码并打包
RUN set -xe; \
	mkdir -p /root/repo ; cd /root/repo ; \
	git clone https://gitee.com/AHEAD4/go-view-serve.git ; \
	cd go-view-serve; \
	mvn -s /settings.xml -DfinalName=app package;
RUN cd /root/repo/go-view-serve/target ; for file in $(find . -name "*.war"); do cp $file ./app.war; break; done ; ls ; sleep 5 ;

# jdk
FROM openjdk:8-jdk-alpine as serer
# 将打包结果复制到centos
COPY --from=builder /root/repo/go-view-serve/target/app.war /app.war

EXPOSE 8080
ENTRYPOINT java -Duser.timezone=Asia/Shanghai -jar app.war